package com.icim.xmtm.exporter.controller;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.icim.csot.exporter.tx.csotshipping.CsotShippingO;
import com.icim.util.XmlConvertUtil;
import com.icim.xmtm.exporter.service.IXmtmExportShippingDataService;

@Controller
public class XmtmShippingdataController {


    @Resource
    private IXmtmExportShippingDataService xmtmExportShippingDataService;
    
    private Logger logger = LoggerFactory.getLogger(XmtmShippingdataController.class);

    @ResponseBody
    @RequestMapping("exportXmtmShippingdata.do")
    public String exportShippingData(String palletId){

        CsotShippingO outTrx = new CsotShippingO();
       
        try {
        	logger.info("new project ...");
            outTrx = xmtmExportShippingDataService.sendShippingData(palletId);
            outTrx.setRtn_code("0000000");
            outTrx.setRtn_mesg("SUCCESS");
        } catch (Exception ex) {
            outTrx.setRtn_code("9999999");
            outTrx.setRtn_mesg(ex.getMessage());
           logger.info("error: {} " ,ex);
        }
        return XmlConvertUtil.obj2Xml(outTrx, "transaction");
    }

}
